local base = _G
module("CLI.query_stock")

function main(f)
	if f == "Query" then
		Query()
	--[[
	elseif then
	--]]
	end
end

function Query()
	base.io.write("Input stock id please:")
	local id = base.io.read()
	local sm = base.require("Function.stock_management")
	local t,c = sm.Query(id)
	base.io.write("\n========== Stroke ==========\n")
	if t == -1 then
		base.io.write("ERROR while querying stock!Code:" .. c .. "\n")
	elseif t[1][1] == nil then
		base.io.write("No such stock!\n")
	else
		base.io.write("SN:" .. (t[1][1] or "Unavailable") .. "\n")
		base.io.write("Name:" .. (t[2][1] or "Unavailable") .. "\n")
		base.io.write("Location:" .. (t[3][1] or "Unavailable") .. "\n")
		base.io.write("TypeID:" .. (t[4][1] or "Unavailable") .. "\n")
		base.io.write("ProduceDate:" .. (t[5][1] or "Unavailable") .. "\n")
		base.io.write("BestBefore:" .. (t[6][1] or "Unavailable") .. "\n")
		base.io.write("Unit:" .. (t[7][1] or "Unavailable") .. "\n")
		base.io.write("Weight:" .. (t[8][1] or "Unavailable") .. "\n")
		base.io.write("Stock_Location:" .. (t[9][1] or "Unavailable") .. "\n")
	end
	base.io.write("\n")
end